import { DatePicker } from "antd";
import React, { useState } from "react";
import dayjs from "dayjs";

const datePicker = () => {
    const [date, setDate] = useState(dayjs('2015-01-08'))
    const disabled = (current) => {
        const currentDay = dayjs(current)
        // 每月只能选择第一天
        const firstDay = currentDay.date() === currentDay.startOf('month').date()
        // 每月只能选择最后一天
        const lastDay = currentDay.date() === currentDay.endOf('month').date()

        return !(lastDay || firstDay)
    }
    return <DatePicker value={date} disabledDate={disabled} onChange={(_, dateString) => setDate(dayjs(`${dateString}`))} />
}

export default datePicker